package Controller;


import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import DAO.*;
import Model.*;

/**
 * Servlet implementation class RankList
 */
@WebServlet("/RankList")
public class RankList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RankList() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
		doProcess(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
		doProcess(request,response);
	}

	protected void doProcess(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
		RankListDAO rankListDAO = DAOFactory.getInstance().getRankListDAO();
		ArrayList<RankListBean> rankList = new ArrayList<RankListBean>();
		try {
			rankList = rankListDAO.findAllRankList(); 
		} catch (Exception e) {
			e.printStackTrace();
		}
		request.setAttribute("RankList", rankList);
		RequestDispatcher rd = request.getRequestDispatcher("RankList.jsp");
		rd.forward(request, response);
	}
}
